package source.control;

import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import source.Enums.Side;
import source.calcCmd.RobotCommand;


public class TableModel extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	String[] col_names = {"time (ms)","v1 (m/s)","v2 (m/s)",};
	@SuppressWarnings("rawtypes")
	Class[] col_types = {String.class, Integer.class, Integer.class};
	
	Vector<RobotCommand> data;
	
	public TableModel(Vector<RobotCommand> dataVector){
		super();
		data = dataVector;
	}
	
	// function for AbstractTableModel
	public int getColumnCount() {
		return 3;
	}

	// function for AbstractTableModel
	public int getRowCount() {
		return data.size();
	}

	// function for AbstractTableModel
	public Object getValueAt(int row, int col) {
		
		RobotCommand ret = data.get(row);
		
		switch (col){
			case 0:
				return ret.getRealTime();
			case 1: 
				return ret.getRealV(Side.RIGHT);
			case 2:
				return ret.getRealV(Side.LEFT);
			default: 
				return null;
		}

	}
	
	// function for AbstractTableModel
	public String getColumnName(int col) {
	      return col_names[col];
	    }

}
